package com.fishingwithme.infrastructure.dtos;

import com.fishingwithme.domain.spots.FishType;
import com.fishingwithme.domain.spots.SpotLvl;
import com.fishingwithme.domain.spots.SpotType;
import com.fishingwithme.infrastructure.utils.CommonUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Data
public class SpotPageDto implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;

    private Long id;
    private String cityCode;
    private String city;
    private Double longitude;
    private Double latitude;
    private String name;
    private SpotLvl lvl;
    private Integer isPrivate;
    private Long fisherId;
    private Integer creditVal;

    @JsonIgnore
    private String spotTypes;
    private List<ObjectNode> sTypes;

    @JsonIgnore
    private String fishTypes;
    private List<ObjectNode> fTypes;

    private Date createdAt;
    private Date updatedAt;
    private Integer isCollected;
    private Date collectedAt;

    public SpotPageDto format() {
        this.setSTypes(CommonUtils.convert(this.getSpotTypes(), SpotType.class));
        this.setFTypes(CommonUtils.convert(this.getFishTypes(), FishType.class));
       return this;
    }
}
